package 练习;

import java.util.Arrays;

public class 数组的拷贝 {
    public static void main(String[] args) {
        int[] array8 = {1,2,3,4,5};
        int[] cope = Arrays.copyOf(array8,array8.length*2);//*2实现了扩容
        int[] cope2 = Arrays.copyOfRange(array8,1,3);
//        java中大部分的范围都是左闭右开区间
        System.out.println(Arrays.toString(cope));
        System.out.println(Arrays.toString(cope2));

        int[] array ={1,2,3,4,5};
        int[] array1 = new int[array.length];
        for (int i = 0; i < array.length; i++) {
            array1[i] = array[i];
        }
        System.out.println(Arrays.toString(array1));

//    注意,这不是拷贝
    int[] array2 = {1,2,3,4};
    int[] array3 =array2;
        System.out.println(Arrays.toString(array3));
    }
}
